{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> 原文地址 [blog.csdn.net](https://blog.csdn.net/cw_huang/article/details/105815345?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param)\n",
    "\n",
    "**系统：**ubuntu 18.04server lts\n",
    "\n",
    "**EMQX 版本：v4.0.6**\n",
    "\n",
    "**停止服务**\n",
    "\n",
    "```\n",
    "emqx stop\n",
    "\n",
    "```\n",
    "\n",
    "**编辑用户名密码配置文件**\n",
    "\n",
    "```\n",
    "vim ./etc/emqx/plugins/emqx_auth_username.conf\n",
    "\n",
    "```\n",
    "\n",
    "增加用户名、密码，密码算法改为 plain，透传\n",
    "\n",
    "![](http://imgconvert.csdnimg.cn/aHR0cHM6Ly9pbWcyMDIwLmNuYmxvZ3MuY29tL2Jsb2cvMjAyMDE0MC8yMDIwMDQvMjAyMDE0MC0yMDIwMDQyNTExNTIyMjI2MS0xNzgwMzc1NzE0LnBuZw?x-oss-process=image/format,png)\n",
    "\n",
    "**关闭匿名登录**\n",
    "\n",
    "```\n",
    "vim /etc/emqx/emqx.conf\n",
    "\n",
    "```\n",
    "\n",
    "查找 allow_anonymous，修改为 false\n",
    "\n",
    "![](http://imgconvert.csdnimg.cn/aHR0cHM6Ly9pbWcyMDIwLmNuYmxvZ3MuY29tL2Jsb2cvMjAyMDE0MC8yMDIwMDQvMjAyMDE0MC0yMDIwMDQyNTExNTMyNTY4Mi0xMjU0MjczMDk0LnBuZw?x-oss-process=image/format,png)\n",
    "\n",
    "启动 emqx 服务\n",
    "\n",
    "```\n",
    "emqx start\n",
    "\n",
    "```\n",
    "\n",
    "进入后台管理界面，启动用户名密码认证。\n",
    "\n",
    "```\n",
    "http://服务器IP:18083\n",
    "\n",
    "```\n",
    "\n",
    "![](http://imgconvert.csdnimg.cn/aHR0cHM6Ly9pbWcyMDIwLmNuYmxvZ3MuY29tL2Jsb2cvMjAyMDE0MC8yMDIwMDQvMjAyMDE0MC0yMDIwMDQyNTExNTQ0MDQ5OC0xNjg0NjU2ODA0LnBuZw?x-oss-process=image/format,png)\n",
    "\n",
    "**此时，使用 MQTT 之前的匿名方式的配置，已经无法登录**\n",
    "\n",
    "**![](http://imgconvert.csdnimg.cn/aHR0cHM6Ly9pbWcyMDIwLmNuYmxvZ3MuY29tL2Jsb2cvMjAyMDE0MC8yMDIwMDQvMjAyMDE0MC0yMDIwMDQyNTExNTUyMzE2NS02NjIwMjA3MS5wbmc?x-oss-process=image/format,png)**\n",
    "\n",
    "MQTT.FX 上，添加用户名密码：\n",
    "\n",
    "![](http://imgconvert.csdnimg.cn/aHR0cHM6Ly9pbWcyMDIwLmNuYmxvZ3MuY29tL2Jsb2cvMjAyMDE0MC8yMDIwMDQvMjAyMDE0MC0yMDIwMDQyNTExNTYyMTgzOS0xODQzOTk5OTkucG5n?x-oss-process=image/format,png)\n",
    "\n",
    "此时可以通过用户名密码登录，订阅主题\n",
    "\n",
    "![](http://imgconvert.csdnimg.cn/aHR0cHM6Ly9pbWcyMDIwLmNuYmxvZ3MuY29tL2Jsb2cvMjAyMDE0MC8yMDIwMDQvMjAyMDE0MC0yMDIwMDQyNTExNTc1MjE2My0xMTc3NDI1MzgxLnBuZw?x-oss-process=image/format,png)\n",
    "\n",
    "同样的方式，我们需要再添加一个用户，用于两个用户之间通讯。\n",
    "\n",
    "我们可以从服务器端登录一个用户，向 MQTT.FX 客户端订阅的 TOPIC 发送信息。可以看到正常收到。\n",
    "\n",
    "![](http://imgconvert.csdnimg.cn/aHR0cHM6Ly9pbWcyMDIwLmNuYmxvZ3MuY29tL2Jsb2cvMjAyMDE0MC8yMDIwMDQvMjAyMDE0MC0yMDIwMDQyNTExNTgyMjMwMS0xOTM3MzQxLnBuZw?x-oss-process=image/format,png)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
